

#---Portmann & Stojanovic 2017: Electoral discrimination against immigrant-origin candidates---#

#load("PrefVotes")

#-------------------- ESTIMATE MODEL (HIERARCHICAL BETA REGRESSION, DV: EXTERNAL PREFERENCE VOTES)

d$extvt_rel_ln <- ln(d$extvt_rel)
  
model11 <- glmmadmb(extvt_rel_ln ~ nonswissnames + incumbent + c_relposition_rc + precumulated + 
                     sex_d + age_c3 + CodeBerufK3 + num_cand + party_c3 + commune +
                     (~1|list_id), data=d, family="Gaussian")

model12 <- glmmadmb(extvt_rel_ln ~ nonswissnames + incumbent + c_relposition_rc + precumulated + 
                     sex_d + age_c3 + CodeBerufK3 + num_cand + party_c3 + nonswissnames:party_c3 + commune + 
                     (~1|list_id), data=d, family="Gaussian")


#-------------- REGRESSION TABLE

htmlreg(list(model11, model12), custom.model.names = c("Model 1", "Model 2"),
        caption = "",
        label = "tab:5",
        stars = c(0.05, 0.01, 0.001),
        dcolumn = TRUE,
        booktabs = TRUE,
        use.packages = FALSE,
        single.row = TRUE,
        include.adjrs = FALSE,
        include.bic = FALSE, file = "Table11.doc")


